#include <stdio.h>

int main () {
	int a, b, c, x, m;
	scanf("%d%d%d%d", &a, &b, &c, &x);

	if(x <= a) {
		m = b * x + c * c;
	} else  {
		m = a*(c - x) + c * c;
	}
	printf("m的值是: %d\n", m);
}
